package ca.camosun.chatbox.network;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import ca.camosun.chatbox.message.Message;

/**
 * Mock messanger implementation.  Echos back any messages sent into received.
 */
public class EchoMessageMailer implements MessageSender, MessageReceiver {
	private BlockingQueue<Message> sent;
	
	public EchoMessageMailer() {
		sent = new LinkedBlockingQueue<Message>();
	}
	
	@Override
	public Message receive() throws InterruptedException {
		return sent.take();
	}

	@Override
	public void send(Message msg) {
		sent.add(msg);
	}

}
